// pages/GroupAudit/GroupAudit.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    active_index: 1,
    groupList:[],
    groupMemberList:[],
    page:1,
    huodongList:[],
    groupListcanyu:[],
    huodongListcanyu:[]
  },

  tabItemShow: function (e) {
    let that = this;
    let index = e.currentTarget.dataset.id;
    console.log(index);
    that.setData({
      active_index: index
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this;
    that.setData({
      activorgroup: options.type
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    if (that.data.activorgroup==2){
      var data = {
        paraUrl: "task/page/member?activity=true&page=" + that.data.page+"&size=6",
        paraData: ''
      }
      var data1 = {
        paraUrl: "attendance/page/member?activity=true&page=" + that.data.page + "&size=6",
        paraData: ''
      }
    } else if (that.data.activorgroup == 11){
      console.log(11)
      var data = {
        paraUrl: "group/list/member",
        paraData: ''
      }
      var data1 = {
        paraUrl: "group-member/list/member",
        paraData: ''
      }
    } else if (that.data.activorgroup == 22) {
      console.log(2)
      var data = {
        paraUrl: "task/page/member?activity=false&page=" + that.data.page + "&size=6",
        paraData: ''
      }
      var data1 = {
        paraUrl: "attendance/page/member?activity=false&page=" + that.data.page + "&size=6",
        paraData: ''
      }
    }else{
      return;
    }
    app.getRequest(data1, function (res) {
      if (res.data.result == 200) {
        if (that.data.activorgroup == 2 || that.data.activorgroup == 22) {
          console.log(res.data.body.content)
          that.setData({
            huodongListcanyu: res.data.body.content
          })
        } else if (that.data.activorgroup == 11 || that.data.activorgroup == 1){
          console.log(res.data.body);
          that.setData({
            groupListcanyu: res.data.body
          })
        }
      }
    })
    app.getRequest(data, function (res) {
      if (res.data.result == 200) {
        if (that.data.activorgroup == 2 || that.data.activorgroup == 22) {
          that.setData({
            huodongList: res.data.body.content
          })
        } else if (that.data.activorgroup == 11 || that.data.activorgroup == 1) {
          that.setData({
            groupList: res.data.body
          })
        }
      } 
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  // 点击查看群组详情
  clickDetail: function (e) {
    var that=this;
    if (that.data.activorgroup == 2 || that.data.activorgroup == 22){
      wx.setStorageSync("taskId", e.currentTarget.id)
      wx.navigateTo({
        url: '/pages/ActivityDetail/ActivityDetail'
      })
    }else{
      wx.setStorageSync('qundetail', e.currentTarget.id);
      wx.navigateTo({
        url: '../GroupDetail/GroupDetail'
      })
    }
    
  }
})